<template>
  <div>
    <h2>登陆页</h2>
    <form @submit.prevent="login">
      <div class="input-row">
        <label for="username">用户名:</label>
        <input type="text" id="username" placeholder="请输入你的账号" v-model="username" required>
      </div>
      <div class="input-row">
        <label for="password">密码:</label>
        <input type="password" id="password" placeholder="请输入你的密码" v-model="password" required>
      </div>
      <button type="submit">登陆</button>
    </form>
  </div>
</template>
  
  
<script>
export default {
  data() {
    return {
      username: '',
      password: '',
      errorMessage: ''
    };
  },
  methods: {
    login() {
      if (this.username === 'admin' && this.password === '123456') {
        this.$router.push('/usercenter');
      } else {
        alert("账号密码错误！")
      }
    }
  }
};
</script>
  
<style>
h2 {
  text-align: center;
  color: #333;
  margin-bottom: 20px;
}

form {
  display: flex;
  flex-direction: column;
  align-items: center;
}

label {
  font-weight: bold;
  margin-bottom: 10px;
  display: inline-block;
  width: 80px;
}

input {
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  margin-bottom: 10px;
  width: 200px;
}

button {
  padding: 10px 20px;
  background-color: #007bff;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

button:hover {
  background-color: #0056b3;
}


.input-row {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}

.input-row label {
  margin-right: 10px;
}
</style>


